<script setup lang="ts">
import { watchEffect, onUnmounted, } from 'vue';
import {debounce} from './utils'
import baseInfoStore from "./stores/baseInfoStore.ts";
import zhCN from 'ant-design-vue/es/locale/zh_CN'
// @ts-ignore
import * as dayjs from 'dayjs'
import 'dayjs/locale/zh-cn';

dayjs.locale('en');


const baseInfo = baseInfoStore()
baseInfo.setWindowWidth(window.innerWidth);
baseInfo.setWindowHeight(window.innerHeight);

watchEffect(() => {
  const handleResize = debounce(() => {
    if (baseInfo.windowWidth !== window.innerWidth) baseInfo.setWindowWidth(window.innerWidth);
    if (baseInfo.windowHeight !== window.innerHeight) baseInfo.setWindowHeight(window.innerHeight);
    console.log('baseInfo.windowWidth', baseInfo.windowWidth)
    console.log('baseInfo.windowHeight', baseInfo.windowHeight)
  }, 400);

  // 监听浏览器窗口尺寸变化
  window.addEventListener('resize', handleResize);

  // 在组件销毁时移除事件监听
  onUnmounted(() => {
    window.removeEventListener('resize', handleResize);
  });
});
</script>

<template>
  <a-config-provider :locale="zhCN">
    <router-view />
  </a-config-provider>
</template>

<style scoped>

</style>
